package palindrome;
import java.util.Scanner;
import java.util.Vector;


/**
 * The Class Palindrome provides searching palindromes (substrings) in string readout from console
 * 
 * @author Mykola Blyk nickblyk@gmail.com
 */
public class Palindrome {
        private String line="";
        private Vector<Integer> firstCoordinatesOfPalindromes =new Vector<Integer>();
        private Vector<Integer> secondCoordinatesOfPalindromes = new Vector<Integer>();
        
        private boolean  checkBorderOfStringAndEqualOfPalindromes(int index, int radiusOfPalindrome, int CONSTANT) {
                return ((index-radiusOfPalindrome>=0) && 
                           (index+radiusOfPalindrome+CONSTANT<line.length()) &&
                           (line.codePointAt(index-radiusOfPalindrome)==
                       line.codePointAt(index+radiusOfPalindrome+CONSTANT)));   
        }

        private void findEvenPalindromes() {
                final int constantForRadius=1;
                for(int index=0; index<line.length(); index++) {
                int radiusOfPalindrome=0;
                
                        while(checkBorderOfStringAndEqualOfPalindromes(index,
                                 radiusOfPalindrome,constantForRadius)) {
                                
                                addCoordinates(index, radiusOfPalindrome, constantForRadius);
                                radiusOfPalindrome++;
                        }
                }
        
        }
        
        private void findOddPalindromes() {
                final int constantForRadius=0;
                for(int index=0;index<line.length(); index++) {
                
                        int RadiusOfPalindrome=1;
                
                        while(checkBorderOfStringAndEqualOfPalindromes(index,
                                 RadiusOfPalindrome, constantForRadius) ) {
                                addCoordinates(index, RadiusOfPalindrome,constantForRadius);
                                RadiusOfPalindrome++;
                        }
                }
        
        }

        public void findPalindromes() {
                findOddPalindromes();
                findEvenPalindromes();
        
        }

        private void addCoordinates(int first, int second, int CONSTANT) {
                firstCoordinatesOfPalindromes.add(first-second);
                secondCoordinatesOfPalindromes.add(first+second+CONSTANT);
        }

        public void  PrintPalindromes() {
                String temp;
                for(int i=0; i<firstCoordinatesOfPalindromes.size(); i++) {
                        temp=line.substring( firstCoordinatesOfPalindromes.elementAt(i), 
                                 secondCoordinatesOfPalindromes.elementAt(i)+1);
                        System.out.println(temp);                       
                }       
        }

        public void setData() {
                Scanner inputData = new Scanner (System.in);
                line= inputData.nextLine();
        }

        public static void main(String [] arg) {
                Palindrome GeneratorOfPalindroms= new Palindrome();
                GeneratorOfPalindroms.setData();
                GeneratorOfPalindroms.findPalindromes();
                GeneratorOfPalindroms.PrintPalindromes();               
        }


}